package com.itheima.proxy.dynamic.jdk;


import org.junit.Test;

import java.lang.reflect.Proxy;

/**
 * @author robin
 * @version 1.0
 */
public class JdkProxyTest {

    @Test
    public void test() {
        //产生一个jdk动态代理对象
        ProxyHandler proxyHandler = new ProxyHandler(new UserServiceImpl());
        // 产生代理对象实现了UserService接口
        UserService userService = (UserService) Proxy.newProxyInstance(UserServiceImpl.class.getClassLoader(), UserServiceImpl.class.getInterfaces(), proxyHandler);
        userService.save(new User(1L, "张三"));
    }
}
